<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('materials', function (Blueprint $table) {
            $table->id();
            $table->string('title')->index();
            $table->unsignedBigInteger('project_id')->index()->comment('所属项目ID');
            $table->unsignedBigInteger('user_id')->default(0)->comment('责任人');
            $table->decimal('price', 10, 2)->default(0);
            $table->string('specs')->default('/')->comment('规格型号');
            $table->string('unit')->default('/')->comment('单位');
            $table->string('sums')->default(0)->comment('数量');
            $table->string('brand')->default('/')->comment('品牌');
            $table->string('remarks')->nullable()->default('/')->comment('备注');
            $table->tinyInteger('type')->index()->default(1)->comment('1主料 2零星材料 3现场采购');
            $table->string('files')->nullable()->default('')->comment('资料文件');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('materials');
    }
};
